package com.injurydetection.www.util.datautil;

import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;

/**
 * Created by sunguiyong on 2020/9/1
 */
public class SerialPort2 {
    private static final String TAG;

    public SerialPort2() {
    }

    boolean chmod777(File file) {
        if (null != file && file.exists()) {
            try {
                Process su = Runtime.getRuntime().exec("/system/bin/su");
                String cmd = "chmod 777 " + file.getAbsolutePath() + "\nexit\n";
                su.getOutputStream().write(cmd.getBytes());
                if (0 == su.waitFor() && file.canRead() && file.canWrite() && file.canExecute()) {
                    return true;
                }
            } catch (InterruptedException | IOException var4) {
                var4.printStackTrace();
            }

            return false;
        } else {
            return false;
        }
    }

    protected native FileDescriptor open(String var1, int var2, int var3);

    protected native void close();

    static {
        System.loadLibrary("SerialPort");
        TAG = SerialPort2.class.getSimpleName();
    }
}
